package com.java8;

import com.dto.Staff;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class StreamTest
{


    public static void main(String[] args) {

        List<String> strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");


      // Long count = strings.stream().filter(string->string.isEmpty()).count();
       // System.out.println(count);

        List<String> filtered=null;
    //    filtered = strings.stream().collect(Collectors.toList());
        filtered = strings.stream().filter(s ->!s.isEmpty()).collect(Collectors.toList());

        List<Staff> staffList = new ArrayList<>();

        Staff staff1 = new Staff();
        staff1.setName("zhangsan");
        staff1.setAge(11L);
        staffList.add(staff1);
        Staff staff2 = new Staff();
        staff2.setName("lisi");
        staff2.setAge(44L);
        staffList.add(staff2);

        Map<Long, String> collect = staffList.stream().collect(Collectors.toMap(Staff::getAge, Staff::getName));
        Map<Long,Staff> staffMap = staffList.stream().collect(Collectors.toMap(Staff::getAge,Function.identity()));
        System.out.println(collect);


        //  filtered = strings.stream().filter(string ->!string.isEmpty()).collect(Collectors.toList());
        System.out.println(filtered);






    }


}
